# 定义全局变量
card_infos = []

def output_menu():
	print('*'*19 + '名片管理系统' + '*'*19)
	print('1: 添加一个新名片')
	print('2: 删除一个名片')
	print('3: 改变一个名片')
	print('4: 查询一个名片')
	print('5: 显示所有名片')
	print('6: 退出系统')
	print('*'*50)	

output_menu()



def add_info():
	# global的目的是告诉开发者这是全局变量
	# global是可加可不加的
	global card_infos
	new_name = input('请输入新的名字:')
	new_qq = input('请输入新的QQ:')
	new_weixin = input('请输入新的微信:')
	new_age = input('请输入新的年龄:')

	# 定义一个新的字典
	new_info = {}
	new_info['new_name'] = new_name
	new_info['new_qq'] = new_qq
	new_info['new_weixin'] = new_weixin
	new_info['new_age'] = new_age

	global card_infos
	card_infos.append(new_info)
	print('添加名片成功,信息如下:')
	print(card_infos)

def find_info():
	global card_infos
	find_name = input('请输入要查找的姓名:')
	find_flag = 0
	for temp in card_infos:
			if find_name == temp['new_name']:
				print('此姓名对应的信息如下:')
				print('%s\t%s\t%s\t%s\t'%(temp['new_name'],temp['new_qq'],temp['new_weixin'],temp['new_age']))
				find_flag = 1
				break
	if find_flag == 0:
		print('查无此人')

while True:
	# 获取用户选择
	num = int(input('请输入功能序号:'))
	if num==1:
		add_info()
	elif num==2:
		pass
	elif num==3:
		pass
	elif num==4:
		find_info()
	elif num==5:
		print('姓名\tQQ\t微信\t年龄\t' )
		for temp in card_infos:
			print('%s\t%s\t%s\t%s\t'%(temp['new_name'],temp['new_qq'],temp['new_weixin'],temp['new_age']))
	elif num==6:
		break
	else:	
		print('您的输入有误,请重新输入:')
	print('')